//
//  IconTableViewCell.m
//  Findif
//
//  Created by appdev on 2018/10/29.
//  Copyright © 2018 Cicel Chen. All rights reserved.
//

#import "IconTableViewCell.h"

@interface IconTableViewCell ()

@property (nonatomic, weak)UIView * backView;
@property (nonatomic, weak)UILabel * titleLabel;
@property (nonatomic, weak)UIImageView * rightImageView;


@end

@implementation IconTableViewCell

- (void)setImage:(UIImage *)image{
    
    _image = image;
    
    self.iconImageView.image = image;
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor clearColor];
    
    UIView * backView = [UIView new];
    
    backView.userInteractionEnabled = YES;
    backView.backgroundColor = ZRWhiteColor;
    backView.layer.cornerRadius = 5 * SCREENH6;
    backView.layer.masksToBounds = YES;
    
    self.backView = backView;
    
    [self.contentView addSubview:self.backView];
    
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.text = @"头像";
    titleLabel.textColor = ZRBlackColor;
    titleLabel.font = [UIFont systemFontOfSize:17 * SCREENH6];
    
    self.titleLabel = titleLabel;
    
    [self.contentView addSubview:self.titleLabel];
    
    
    UIImageView * rightImageView = [UIImageView new];
    
    rightImageView.image = [UIImage imageNamed:@"右箭头"];
    
    self.rightImageView = rightImageView;
    
    [self.contentView addSubview:self.rightImageView];
    
    
    UIImageView * iconImageView = [UIImageView new];
    
//    iconImageView.image = IMAGENAME(@"右箭头");
    iconImageView.backgroundColor = [UIColor lightGrayColor];
    iconImageView.layer.cornerRadius = 25 * SCREENH6;
    iconImageView.layer.masksToBounds = YES;
    
    self.iconImageView = iconImageView;
    
    [self.contentView addSubview:self.iconImageView];
    
    
    
}


- (void)layoutSubviews{
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
        make.trailing.mas_equalTo(self.contentView).offset(-15 * SCREENH6);
        make.centerY.mas_equalTo(self.contentView);
        make.height.mas_equalTo(60 * SCREENH6);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.backView);
        make.leading.mas_equalTo(self.backView).offset(10 * SCREENH6);
    }];
    
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.backView);
        make.trailing.mas_equalTo(self.backView).offset(-10 * SCREENH6);
        make.width.mas_equalTo(7 * SCREENH6);
        make.height.mas_equalTo(12.5 * SCREENH6);
    }];
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.rightImageView.mas_leading).offset(-15 * SCREENH6);
        make.centerY.mas_equalTo(self.rightImageView);
        make.width.height.mas_equalTo(50 * SCREENH6);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
